package com.swak.frame.support;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role;
import org.springframework.util.CollectionUtils;

import com.swak.frame.filter.ApiFilter;

@Configuration(proxyBeanMethods = false)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class DelegatingServiceConfiguration extends ServiceConfigurationSupport {

    private final ServiceConfigurerComposite configurers = new ServiceConfigurerComposite();

    @Autowired(required = false)
    public void setConfigurers(List<SwakServiceConfigurer> configurers) {
        if (!CollectionUtils.isEmpty(configurers)) {
            this.configurers.addSwakServiceConfigurer(configurers);
        }
    }

    @Override
    protected void configureFilterHandler(ConfigPipeline<ApiFilter> filtersPipeline) {
        this.configurers.configureFilterHandler(filtersPipeline);
    }

    @Override
    protected void extendconfigureFilters(ConfigPipeline<ApiFilter> filtersPipeline) {
        this.configurers.extendConfigureFilters(filtersPipeline);
    }

}
